#ifndef __COMM_HPP__
#define __COMM_HPP__

#include <iostream>
#include <string>
#include<string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include<unistd.h>
#include <fcntl.h>


using namespace std;

#define Path "fifo"
#define Mode 0666

class Fifo
{
public:
    Fifo(const string &pathname)
        : _pathname(pathname)
    {
        int n = mkfifo(_pathname.c_str(), Mode);
        if (n == 0)
        {
            cout << "mkfifo success" << endl;
        }
        else
        {
            cout << "mkfifo failed ,errno:" << errno << " errstring:" << strerror(errno) << endl;
        }
    }

    ~Fifo()
    {
        int n = unlink(_pathname.c_str());
        if (n == 0)
        {
            cout << "unlink success" << endl;
        }
        else
        {
            cout << "unlink failed ,errno:" << errno << " errstring:" << strerror(errno) << endl;
        }
    }

private:
    string _pathname;
};

#endif